<template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="题目" width="250">
        <template slot-scope="scope">
          <router-link
            :to="{ path: '/madmin_topic', query: { id: scope.row.id } }"
            >{{ scope.row.topic_name }}</router-link
          >
        </template>
      </el-table-column>
      <el-table-column label="来源" width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.topic_from }}</span>
        </template>
      </el-table-column>
      <el-table-column label="类型" width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.topic_type }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">
            通过
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  created () {
    this.gettopic();
  },
  data () {
    return {
      tableData: [],
    };
  },
  methods: {
    gettopic () {
      this.$http.get("http://127.0.0.1:8080/minAdmin/get_topic").then((res) => {
        // console.log(res);
        this.tableData = res.data.data;
      });
    },
    handleEdit (index, row) {
      //  console.log(index, row);
      this.$http
        .post(
          "http://127.0.0.1:8080/minAdmin/pass_topic",
          this.$qs.stringify(row)
        )
        .then((res) => {
          // console.log(res);
          this.gettopic();
          // this.tableData = res.data.data;
        });
    },
  },
};
</script>
<style lang="less" scoped>
</style>
